import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { NumberlevelinfoVO, NumberlevelinfoForm, NumberlevelinfoQuery } from '@/api/numberlevelinfo/numberlevelinfo/types';

/**
 * 查询层级信息列表
 * @param query
 * @returns {*}
 */

export const listNumberlevelinfo = (query?: NumberlevelinfoQuery): AxiosPromise<NumberlevelinfoVO[]> => {
  return request({
    url: '/numberLevelInfo/numberLevelInfo/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询层级信息详细
 * @param id
 */
export const getNumberlevelinfo = (id: string | number): AxiosPromise<NumberlevelinfoVO> => {
  return request({
    url: '/numberLevelInfo/numberLevelInfo/' + id,
    method: 'get'
  });
};

/**
 * 新增层级信息
 * @param data
 */
export const addNumberlevelinfo = (data: NumberlevelinfoForm) => {
  return request({
    url: '/numberLevelInfo/numberLevelInfo',
    method: 'post',
    data: data
  });
};

/**
 * 修改层级信息
 * @param data
 */
export const updateNumberlevelinfo = (data: NumberlevelinfoForm) => {
  return request({
    url: '/numberLevelInfo/numberLevelInfo',
    method: 'put',
    data: data
  });
};

/**
 * 删除层级信息
 * @param id
 */
export const delNumberlevelinfo = (id: string | number | Array<string | number>) => {
  return request({
    url: '/numberLevelInfo/numberLevelInfo/' + id,
    method: 'delete'
  });
};


/**
 * 重新生成层级信息
 */
export const regenerateLevelInfo =() => {
  return request({
    url: '/numberLevelInfo/numberLevelInfo/generate', // URL应与后端Controller中定义的端点相匹配
    method: 'post',

});
};



/**
 * 根据ID列表导出会员层级信息
 * @param ids 需要导出的会员ID层级信息
 */
export const exportSelectedLevelInfo = (ids: Array<string | number>): AxiosPromise<Blob> => {
  return request({
    url: '/numberLevelInfo/numberLevelInfo/exportSelected',
    method: 'post',
    data: ids,
    headers: {
      'Content-Type': 'application/json'
    },
    responseType: 'blob' // 确保响应类型为blob，以便处理文件下载
  });
};



/**
 * 清空表数据
 */
export const clearNumberlevelinfo = () => {
  return request({
    url: '/numberLevelInfo/numberLevelInfo/clear',
    method: 'delete'
  });
};